<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>一次性解码多个 MIME 头字段</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.iconv-mime-decode-headers" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">iconv_mime_decode_headers</h1>
  <p class="verinfo">(PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">iconv_mime_decode_headers</span> &mdash; <span class="dc-title">一次性解码多个 <em>MIME</em> 头字段</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.iconv-mime-decode-headers-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>iconv_mime_decode_headers</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$encoded_headers</code></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$mode</code><span class="initializer"> = 0</span></span>
   [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$charset</code><span class="initializer"> = ini_get(&quot;iconv.internal_encoding&quot;)</span></span>
  ]] ) : <span class="type">array</span></div>

  <p class="para rdfs-comment">
   一次性解码多个 <em>MIME</em> 头字段。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.iconv-mime-decode-headers-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<code class="parameter">encoded_headers</code></dt>

     <dd>

      <p class="para">
       编码过的头，是一个字符串。
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">mode</code></dt>

     <dd>

      <p class="para">
       <code class="parameter">mode</code> 决定了 <span class="function"><strong>iconv_mime_decode_headers()</strong></span> 遇到畸形 <em>MIME</em> 头字段时的行为。
       你可以指定为以下位掩码的任意组合。
       <table class="doctable table">
        <caption><strong><span class="function"><strong>iconv_mime_decode_headers()</strong></span> 接受的位掩码</strong></caption>
        
         <thead>
          <tr>
           <th>值</th>
           <th>常量</th>
           <th>描述</th>
          </tr>

         </thead>

         <tbody class="tbody">
          <tr>
           <td>1</td>
           <td>ICONV_MIME_DECODE_STRICT</td>
           <td>
            如果设置了，给定的头将会以 <a href="http://www.faqs.org/rfcs/rfc2047" class="link external">&raquo;&nbsp;RFC2047</a> 定义的标准完全一致。
            这个选项默认禁用，因为大量有问题的邮件用户代理不遵循标准并产生不正确的 <em>MIME</em> 头。
           </td>
          </tr>

          <tr>
           <td>2</td>
           <td>ICONV_MIME_DECODE_CONTINUE_ON_ERROR</td>
           <td>
            如果设置了，<span class="function"><strong>iconv_mime_decode_headers()</strong></span> 尝试忽略任何语法错误并继续处理指定的头。
           </td>
          </tr>

         </tbody>
        
       </table>

      </p>
     </dd>

    
    
     <dt>
<code class="parameter">charset</code></dt>

     <dd>

      <p class="para">
       可选参数 <code class="parameter">charset</code> 指定了字符集结果的表现。
       如果省略了，将使用
       <a href="iconv.configuration.html" class="link">iconv.internal_encoding</a>。
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.iconv-mime-decode-headers-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回 <code class="parameter">encoded_headers</code> 指定的 <em>MIME</em> 头的整套关联数组，解码时出现错误则返回 <strong><code>FALSE</code></strong>。
  </p>
  <p class="para">
   返回元素的每个键代表独立字段名，相应的元素代表一个字段值。
   如果有多个同一名称的字段，
   <span class="function"><strong>iconv_mime_decode_headers()</strong></span> 自动将他们按出现顺序结合成数字索引的数组。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.iconv-mime-decode-headers-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-2890">
    <p><strong>Example #1 <span class="function"><strong>iconv_mime_decode_headers()</strong></span> 例子</strong></p>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$headers_string&nbsp;</span><span style="color: #007700">=&nbsp;&lt;&lt;&lt;EOF<br /></span><span style="color: #DD0000">Subject:&nbsp;=?UTF-8?B?UHLDvGZ1bmcgUHLDvGZ1bmc=?=<br />To:&nbsp;example@example.com<br />Date:&nbsp;Thu,&nbsp;1&nbsp;Jan&nbsp;1970&nbsp;00:00:00&nbsp;+0000<br />Message-Id:&nbsp;&lt;example@example.com&gt;<br />Received:&nbsp;from&nbsp;localhost&nbsp;(localhost&nbsp;[127.0.0.1])&nbsp;by&nbsp;localhost<br />&nbsp;&nbsp;&nbsp;&nbsp;with&nbsp;SMTP&nbsp;id&nbsp;example&nbsp;for&nbsp;&lt;example@example.com&gt;;<br />&nbsp;&nbsp;&nbsp;&nbsp;Thu,&nbsp;1&nbsp;Jan&nbsp;1970&nbsp;00:00:00&nbsp;+0000&nbsp;(UTC)<br />&nbsp;&nbsp;&nbsp;&nbsp;(envelope-from&nbsp;example-return-0000-example=example.com@example.com)<br />Received:&nbsp;(qmail&nbsp;0&nbsp;invoked&nbsp;by&nbsp;uid&nbsp;65534);&nbsp;1&nbsp;Thu&nbsp;2003&nbsp;00:00:00&nbsp;+0000<br /><br /></span><span style="color: #007700">EOF;<br /><br /></span><span style="color: #0000BB">$headers&nbsp;</span><span style="color: #007700">=&nbsp;&nbsp;</span><span style="color: #0000BB">iconv_mime_decode_headers</span><span style="color: #007700">(</span><span style="color: #0000BB">$headers_string</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"ISO-8859-1"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$headers</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
     </div>

     <div class="example-contents"><p>以上例程会输出：</p></div>
     <div class="example-contents screen">
<div class="cdata"><pre>
Array
(
    [Subject] =&gt; Prüfung Prüfung
    [To] =&gt; example@example.com
    [Date] =&gt; Thu, 1 Jan 1970 00:00:00 +0000
    [Message-Id] =&gt; &lt;example@example.com&gt;
    [Received] =&gt; Array
        (
            [0] =&gt; from localhost (localhost [127.0.0.1]) by localhost with SMTP id example for &lt;example@example.com&gt;; Thu, 1 Jan 1970 00:00:00 +0000 (UTC) (envelope-from example-return-0000-example=example.com@example.com)
            [1] =&gt; (qmail 0 invoked by uid 65534); 1 Thu 2003 00:00:00 +0000
        )

)
</pre></div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.iconv-mime-decode-headers-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="iconv_mime_decode.html" class="function" rel="rdfs-seeAlso">iconv_mime_decode()</a> - 解码一个MIME头字段</span></li>
    <li class="member"><span class="function"><a href="mb_decode_mimeheader.html" class="function" rel="rdfs-seeAlso">mb_decode_mimeheader()</a> - 解码 MIME 头字段中的字符串</span></li>
    <li class="member"><span class="function"><a href="imap_mime_header_decode.html" class="function" rel="rdfs-seeAlso">imap_mime_header_decode()</a> - Decode MIME header elements</span></li>
    <li class="member"><span class="function"><a href="imap_base64.html" class="function" rel="rdfs-seeAlso">imap_base64()</a> - Decode BASE64 encoded text</span></li>
    <li class="member"><span class="function"><a href="imap_qprint.html" class="function" rel="rdfs-seeAlso">imap_qprint()</a> - Convert a quoted-printable string to an 8 bit string</span></li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>